home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- *
- * Nom: tracewin.c
- * Desc: fonctions de traçage dans les fenetres
- *
- *
- * version : $VER: tracewin.c 2.2 (11.04.98)
- *****************************************************************************
- */
- #include <exec/memory.h>
- #include <graphics/rastport.h>
- #include <proto/graphics.h>
- #include <proto/exec.h>
- #include <math.h>
- #include "utils.h"
- #include "tracewin.h"
-
-
-
-
- struct pt ptSec,
- ptMin,
- ptHeu ;
- ULONG mX, mY ;
-
- void initwin(idWin * prj) {
- int i ;
-
- mX = prj->backWin.width / 2 ;
- mY = prj->backWin.height / 2 ;
- if (prj->RP1) {
-
- SetAPen(prj->RP1, prj->backWin.cmap[COL_TIC].reg) ; // couleur jaune
- for(i = 0; i < 360; i=i+30) {
- /* trace les repères des heures
- */
- Move(prj->RP1, ULONG(cos(PI*i/180.0) * (mX-mX/10L)) + mX, ULONG(sin(PI*i/180.0) * (mY-mY/10L)) + mY) ;
- Draw(prj->RP1, ULONG(cos(PI*i/180.0) * mX) + mX, ULONG(sin(PI*i/180.0) * mY) + mY) ;
- }
- }
- /* initalisation des points des aiguilles
- */
- /* secondes
- */
- ptSec.points = 2 ;
- ptSec.fill = FALSE ;
- ptSec.pt_AI = NULL ; // needed when freeing
- ptSec.pt_buffer = NULL ; // idem
- ptSec.A[0] = 0 ;
- ptSec.A[1] = 180 ;
- ptSec.M[0] = 5.0 ;
- ptSec.M[1] = 1.2 ;
- ptSec.angle = ANGLE_S ;
- /* heures
- */
- ptHeu.points = 5 ;
- ptHeu.fill = FALSE ;
- ptHeu.pt_AI = AllocVec(sizeof(struct AreaInfo), MEMF_PUBLIC|MEMF_CLEAR) ;
- ptHeu.pt_buffer = AllocVec(10 * ptHeu.points, MEMF_PUBLIC) ;
- ptHeu.A[0] = 0 ;
- ptHeu.A[1] = 100 ;
- ptHeu.A[2] = 180 ;
- ptHeu.A[3] = -100 ;
- ptHeu.A[4] = 0 ;
- ptHeu.M[0] = 3.0 ;
- ptHeu.M[1] = 1.1 ;
- ptHeu.M[2] = 1.2 ;
- ptHeu.M[3] = 1.1 ;
- ptHeu.M[4] = 3.0 ;
- ptHeu.angle = ANGLE_H ;
-
- /* minutes
- */
- ptMin.points = 5 ;
- ptMin.fill = FALSE ;
- ptMin.pt_AI = AllocVec(sizeof(struct AreaInfo), MEMF_PUBLIC|MEMF_CLEAR) ;
- ptMin.pt_buffer = AllocVec(10 * ptMin.points, MEMF_PUBLIC) ;
- ptMin.A[0] = 0 ;
- ptMin.A[1] = 150 ;
- ptMin.A[2] = 180 ;
- ptMin.A[3] = -150 ;
- ptMin.A[4] = 0 ;
- ptMin.M[0] = 4 ;
- ptMin.M[1] = 1.3 ;
- ptMin.M[2] = 1.2 ;
- ptMin.M[3] = 1.3 ;
- ptMin.M[4] = 4 ;
- ptMin.angle = ANGLE_M ;
- effacer(prj) ;
- retracer(prj) ;
-
- }
- void free_twin(idWin * prj) {
- if (ptSec.pt_AI) FreeVec(ptSec.pt_AI) ;
- if (ptSec.pt_buffer) FreeVec(ptSec.pt_buffer) ;
-
- if (ptMin.pt_AI) FreeVec(ptMin.pt_AI) ;
- if (ptMin.pt_buffer) FreeVec(ptMin.pt_buffer) ;
-
- if (ptHeu.pt_AI) FreeVec(ptHeu.pt_AI) ;
- if (ptHeu.pt_buffer) FreeVec(ptHeu.pt_buffer) ;
-
-
- }
-
- void reinit_win(idWin * prj) {
- free_twin(prj) ;
- initwin(prj) ;
- }
-
- void effacer(idWin * prj) {
- // BltBitMapRastPort(prj->wb->RastPort.BitMap, prj->backWin.posX, prj->backWin.posY, prj->RP1, 0, 0, prj->backWin.width, prj->backWin.height, 0xc0) ;
- WaitBlit() ;
- BltBitMapRastPort(prj->RP1->BitMap, 0,0, prj->RP2, 0, 0, prj->backWin.width, prj->backWin.height, 0xc0) ;
- }
- void retracer(idWin * prj) {
- SetAPen(prj->RP2, prj->backWin.cmap[COL_SEC].reg) ;
- tracerAiguilles(prj, &ptSec, prj->sec, NULL) ;
- SetAPen(prj->RP2, prj->backWin.cmap[COL_MIN].reg) ;
- tracerAiguilles(prj, &ptMin, prj->min, NULL) ;
- SetAPen(prj->RP2, prj->backWin.cmap[COL_HEU].reg) ;
- tracerAiguilles(prj, &ptHeu, prj->heu, prj->min/2) ;
- WaitBlit() ;
- BltBitMapRastPort(prj->RP2->BitMap, 0,0, prj->win->RPort, 0, 0, prj->backWin.width, prj->backWin.height, 0xc0) ;
- }
- void tracerAiguilles(idWin * prj, struct pt * ptAigu, UBYTE p_time, UBYTE an_inc) {
- int i ;
- if (ptAigu->pt_AI) {
- // reinitialise AreaInfo
- ptAigu->pt_AI->Count = NULL ; // reset vertices
- // prj->win->RPort->AreaInfo = ptAigu->pt_AI ; // set the areainfo
- }
-
- Move(prj->RP2, mX+(ULONG)(cos(PI*(ptAigu->A[0]+p_time*ptAigu->angle+an_inc-90.0)/180.0)*(mX-mX/ptAigu->M[0])),
- mY+(ULONG)(sin(PI*(ptAigu->A[0]+p_time*ptAigu->angle+an_inc-90.0)/180.0)*(mY-mY/ptAigu->M[0]))) ;
-
- if (!ptAigu->fill) {
- // tracer sans remplissage
- // no fill
- for(i = 0; i<ptAigu->points; i++)
- Draw(prj->RP2, mX+(ULONG)(cos(PI*(ptAigu->A[i]+p_time*ptAigu->angle+an_inc-90.0)/180.0)*(mX-mX/ptAigu->M[i])),
- mY+(ULONG)(sin(PI*(ptAigu->A[i]+p_time*ptAigu->angle+an_inc-90.0)/180.0)*(mY-mY/ptAigu->M[i]))) ;
- }else {
- /* // avec remplissage
- // fill
-
- InitArea(ptAigu->pt_AI, ptAigu->pt_buffer, ptAigu->points) ;
- AreaMove(prj->win->RPort, mX+(ULONG)(cos(PI*(ptAigu->A[0]+p_time*ptAigu->angle+an_inc-90.0)/180.0)*(mX-mX/ptAigu->M[0])),
- mY+(ULONG)(sin(PI*(ptAigu->A[0]+p_time*ptAigu->angle+an_inc-90.0)/180.0)*(mY-mY/ptAigu->M[0]))) ;
-
- for(i = 0; i < ptAigu->points; i++)
- AreaDraw(prj->win->RPort, mX+(ULONG)(cos(PI*(ptAigu->A[i]+p_time*ptAigu->angle+an_inc-90.0)/180.0)*(mX-mX/ptAigu->M[i])),
- mY+(ULONG)(sin(PI*(ptAigu->A[i]+p_time*ptAigu->angle+an_inc-90.0)/180.0)*(mY-mY/ptAigu->M[i]))) ;
-
- AreaEnd(prj->win->RPort) ;*/
- }
- }
-
- void init_bitmap(idWin * prj) {
- /* initialize tmp rastport and bitmap
- */
- prj->RP1 = AllocVec(sizeof(struct RastPort), MEMF_PUBLIC) ;
- prj->RP2 = AllocVec(sizeof(struct RastPort), MEMF_PUBLIC) ;
- InitRastPort(prj->RP1) ;
- InitRastPort(prj->RP2) ;
- prj->RP1->BitMap = AllocBitMap(prj->backWin.width, prj->backWin.height, prj->wb->RastPort.BitMap->Depth, BMF_CLEAR|BMF_DISPLAYABLE, NULL) ;
- prj->RP2->BitMap = AllocBitMap(prj->backWin.width, prj->backWin.height, prj->wb->RastPort.BitMap->Depth, BMF_CLEAR|BMF_DISPLAYABLE, NULL) ;
- WaitBlit() ;
- BltBitMapRastPort(prj->wb->RastPort.BitMap, prj->backWin.posX, prj->backWin.posY, prj->RP1, 0, 0, prj->backWin.width, prj->backWin.height, 0xc0) ;
- }
-
- void free_bitmap(idWin * prj) {
-
-
- if (prj->RP1 && prj->RP1->BitMap) FreeBitMap(prj->RP1->BitMap) ;
- if (prj->RP2 && prj->RP2->BitMap) FreeBitMap(prj->RP2->BitMap) ;
- if (prj->RP1) FreeVec(prj->RP1) ;
- if (prj->RP2) FreeVec(prj->RP2) ;
- prj->RP1 = prj->RP2 = NULL ;
- }
-
-